#ifndef DOCUMENT_H
#define DOCUMENT_H

#include "clipbord.h"

#define FILENAME_LEN 64
class Document
{
private:
	int max_line;
	int max_column;

	int pos_line;
	int pos_column;

	int offset_line;
	int offset_column;
	
	int *columns;
	
	int total_line;
	
	WINDOW *bufferWindow;
	Clipbord clipbord;
	
	char fileName[FILENAME_LEN];
protected:
	const char *findWord(bool del);
	const char *deleteLine(bool del);
public:
	Document();
	~Document();

	bool moveTo(int line, int column);
	bool moveOffset(int line, int column);
	
	bool feedLine();
	bool backspace();
	bool keydelete();
	bool keyhome();
	bool keyend();
	bool keypageup();
	bool keypagedown();
	bool keytab();
	
	bool add(char ch);
	bool add(const char *str);

	bool moveAdd(int line, int column, char ch);
	bool moveAdd(int line, int column, char *str);

	bool loadFile(const char *fileName);
	bool saveFile(const char *fileName);

	// Delete the current character
	bool del();
	
	// Delete the former character
	bool del(int n);
	
	// Cut the current word
	bool cut();
	
	// Cut the current line
	bool cutLine();
	
	// Copy the current line
	bool copyLine();
	
	// Copy the current word
	bool copy();
		
	// Past the current content of the clipbord into editor
	bool past();
	
	// Find the key word and high light it
	bool find(const char *keyword);
	
	// Replace the key word with the following one
	bool replace(const char *keyword, const char *replaceword);
	
	int getPosLine();
	int getPosColumn();
	int getOffsetLine();
	int getOffsetColumn();
	
	int getMaxLine();
	int getMaxColumn();
	
	WINDOW *getBufferWindow();
	
};

#endif//DOCUMENT_H
